//
//  LZNotificationSettingViewController.m
//  laziz_Consumer
//
//  Created by XMac on 16/10/31.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZNotificationSettingViewController.h"

@interface LZNotificationSettingCell : UITableViewCell

@property (strong, nonatomic) IBOutlet UILabel *titleLabel;

@property (strong, nonatomic) IBOutlet UILabel *statusLabel;

@end
@implementation LZNotificationSettingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.titleLabel.text = LZLocalizedString(@"setting_new_message_notifications", nil);
}

@end


@interface LZNotificationSettingViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) IBOutlet UITableView *notificationTableView;


@property (strong, nonatomic) IBOutlet LZNotificationSettingCell *notificationCell;



@end

@implementation LZNotificationSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.umLogPageViewName = @"通知页面";
    
    self.title = LZLocalizedString(@"setting_notification", @"");
    
    [self configUI];
}

-(void)viewDidLayoutSubviews{
    if ([_notificationTableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [_notificationTableView  setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
    }
    
    if ([_notificationTableView  respondsToSelector:@selector(setLayoutMargins:)]) {
        [_notificationTableView  setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma
#pragma mark Private method
-(void)configUI{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 320, 70)];
    
    label.text = LZLocalizedString(@"setting_notification_remind", @"");
    
    label.font = [UIFont systemFontOfSize:14];
    
    label.numberOfLines = 0;
    
    label.textColor = UIColorFromRGB(0x999999, 1);
    
    _notificationTableView.tableFooterView = label;
    
    _notificationTableView.backgroundColor = UIColorFromRGB(0xF9F7F7, 1);
    
    
    UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
    _notificationCell.statusLabel.text = UIUserNotificationTypeNone == setting.types ?LZLocalizedString(@"switch_off", @""):LZLocalizedString(@"switch_on", @"");
}

#pragma
#pragma mark UITableViewDelegate

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 55;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    return self.notificationCell;
}



@end
